<?php

namespace Admin\Controller;

class FeedbackController extends AdminController
{
	public function index($record = ''){
		$record = empty($record) ? 0 : $record;
		$_GET['record'] = $record;
		$lists = D('Feedback') -> feedbackList($record);
		// echo M() -> _sql();
		// dump($lists);die;
		$this -> assign('lists', $lists);
		$this -> display();
	}

	/**
	 * 修改课程条目状态：未记录，已记录，删除
	 * @return [type] [description]
	 */
	public function edit(){
		if (IS_AJAX) {
			$id = I('post.id');
			$val = I('post.val');
			$flag = I('post.flag');
			if (D('Feedback') -> edit($id, $val, $flag)) {
				$this -> ajaxReturn('操作成功');
			} else {
				$this -> ajaxReturn('出错了');
			}
		} elseif (IS_POST) {
			// $ids = implode(',', I('post.ids'));
			if (I('post.flag') == 'record') {
				$val = 1;
			}
			if (I('post.flag') == 'status') {
				$val = 2;
			}
			if (D('Feedback') -> edit(I('post.ids'), $val, I('post.flag'))) {
				$this -> success('操作成功');
			} else {
				$this -> error('操作失败');
			}
		}
	}
}
